home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / cvs-1.8 / cvs-1 / cvs-1.8.1 / src / no_diff.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-06  |  3.5 KB  |  130 lines

  1. /*
  2.  * Copyright (c) 1992, Brian Berliner and Jeff Polk
  3.  * Copyright (c) 1989-1992, Brian Berliner
  4.  * 
  5.  * You may distribute under the terms of the GNU General Public License as
  6.  * specified in the README file that comes with the CVS 1.4 kit.
  7.  * 
  8.  * No Difference
  9.  * 
  10.  * The user file looks modified judging from its time stamp; however it needn't
  11.  * be.  No_difference() finds out whether it is or not. If it is not, it
  12.  * updates the administration.
  13.  * 
  14.  * returns 0 if no differences are found and non-zero otherwise
  15.  */
  16.  
  17. #include "cvs.h"
  18.  
  19. int
  20. No_Difference (file, vers, entries, repository, update_dir)
  21.     char *file;
  22.     Vers_TS *vers;
  23.     List *entries;
  24.     char *repository;
  25.     char *update_dir;
  26. {
  27.     Node *p;
  28.     char tmp[L_tmpnam+1];
  29.     int ret;
  30.     char *ts, *options;
  31.     int retcode = 0;
  32.     char *tocvsPath;
  33.  
  34.     if (!vers->srcfile || !vers->srcfile->path)
  35.     return (-1);            /* different since we couldn't tell */
  36.  
  37.     if (vers->entdata && vers->entdata->options)
  38.     options = xstrdup (vers->entdata->options);
  39.     else
  40.     options = xstrdup ("");
  41.  
  42.     retcode = RCS_checkout (vers->srcfile->path, NULL, vers->vn_user, options,
  43.                             tmpnam (tmp), 0, 0);
  44.     if (retcode == 0)
  45.     {
  46. #if 0
  47.     /* Why would we want to munge the modes?  And only if the timestamps
  48.        are different?  And even for commands like "cvs status"????  */
  49.     if (!iswritable (file))        /* fix the modes as a side effect */
  50.         xchmod (file, 1);
  51. #endif
  52.  
  53.     tocvsPath = wrap_tocvs_process_file (file);
  54.  
  55.     /* do the byte by byte compare */
  56.     if (xcmp (tocvsPath == NULL ? file : tocvsPath, tmp) == 0)
  57.     {
  58. #if 0
  59.         /* Why would we want to munge the modes?  And only if the
  60.            timestamps are different?  And even for commands like
  61.            "cvs status"????  */
  62.         if (cvswrite == FALSE)    /* fix the modes as a side effect */
  63.         xchmod (file, 0);
  64. #endif
  65.  
  66.         /* no difference was found, so fix the entries file */
  67.         ts = time_stamp (file);
  68.         Register (entries, file,
  69.               vers->vn_user ? vers->vn_user : vers->vn_rcs, ts,
  70.               options, vers->tag, vers->date, (char *) 0);
  71. #ifdef SERVER_SUPPORT
  72.         if (server_active)
  73.         {
  74.         /* We need to update the entries line on the client side.  */
  75.         server_update_entries
  76.           (file, update_dir, repository, SERVER_UPDATED);
  77.         }
  78. #endif
  79.         free (ts);
  80.  
  81.         /* update the entdata pointer in the vers_ts structure */
  82.         p = findnode (entries, file);
  83.         vers->entdata = (Entnode *) p->data;
  84.  
  85.         ret = 0;
  86.     }
  87.     else
  88.         ret = 1;            /* files were really different */
  89.         if (tocvsPath)
  90.     {
  91.         /* Need to call unlink myself because the noexec variable
  92.          * has been set to 1.  */
  93.         if (trace)
  94.         (void) fprintf (stderr, "%c-> unlink (%s)\n",
  95. #ifdef SERVER_SUPPORT
  96.                 (server_active) ? 'S' : ' ',
  97. #else
  98.                 ' ',
  99. #endif
  100.                 tocvsPath);
  101.         if (unlink (tocvsPath) < 0)
  102.         error (0, errno, "could not remove %s", tocvsPath);
  103.     }
  104.     }
  105.     else
  106.     {
  107.     if (update_dir[0] == '\0')
  108.         error (0, retcode == -1 ? errno : 0,
  109.            "could not check out revision %s of %s",
  110.            vers->vn_user, file);
  111.     else
  112.         error (0, retcode == -1 ? errno : 0,
  113.            "could not check out revision %s of %s/%s",
  114.            vers->vn_user, update_dir, file);
  115.     ret = -1;            /* different since we couldn't tell */
  116.     }
  117.  
  118.     if (trace)
  119. #ifdef SERVER_SUPPORT
  120.     (void) fprintf (stderr, "%c-> unlink2 (%s)\n",
  121.             (server_active) ? 'S' : ' ', tmp);
  122. #else
  123.     (void) fprintf (stderr, "-> unlink (%s)\n", tmp);
  124. #endif
  125.     if (unlink (tmp) < 0)
  126.     error (0, errno, "could not remove %s", tmp);
  127.     free (options);
  128.     return (ret);
  129. }
  130.